import { Component } from 'react';
import Taro,{ getCurrentInstance } from '@tarojs/taro';
import { View, Text } from '@tarojs/components'
import classnames from 'classnames'
import UserLoginView from './view'
import './index.scss'

interface State{
  distributionUserId: string,
	value:string
}
export default class UserLogin extends Component {
	$instance = getCurrentInstance()
  constructor(props) {
    super(props)
		this.state = {
      distributionUserId: '',
			value:false
    }
  }

	componentDidMount () {
    const { duid } = this.$instance.router.params
		console.log('duid',duid)
    this.setState({
			distributionUserId:duid
		})

  }
	handleChange=(e)=>{
		console.log(e)
		this.setState({
			value:e
		})
	}
	handleCheck() {
    const { value } = this.state
		this.setState({
			value:!value
		})
  }
  render() {
		let {distributionUserId = '',value} = this.state
		console.log('distributionUserId',distributionUserId)
    return (
      <View className='user-login'>
        <UserLoginView distributionUserId={distributionUserId} value={value}/>
				{
					process.env.TARO_ENV === 'weapp' ? <View className="agreement"  onClick={this.handleCheck.bind(this)} >
					<View data-value='all' className={classnames('check', value && 'act')} >
							<View className='at-icon at-icon-check'></View>
						</View>
						已仔细阅读并同意<Text onClick={() => { Taro.navigateTo({ url: '/pages/user/agreement/index' }) }} className='text'>《集群车宝协议》</Text>
					</View> : null
				}

      </View>
    )
  }
}
